package com.macro.mall.oms.util;

import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

/**
 * class
 *
 * @author xuyanjun
 * @date 2019-08-29
 */
public class OrderNoGenerateUtils {

    private static Random random = new Random();

    /**
     * 获取下一个订单号
     *
     * @return 单号
     */
    public static String nextNo() {
        LocalDateTime now = LocalDateTime.now();
        String nowFormat = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));

        DecimalFormat df = new DecimalFormat("000000");
        String numberFormat = df.format(random.nextInt(100000));

        String orderNo = nowFormat + numberFormat;
        return orderNo;
    }
}
